package ideamaps.action;


import ideamaps.domain.User;
import ideamaps.manager.UserManager;

import com.opensymphony.xwork2.Preparable;
import com.taillive.core.web.StrutsAction;

public class MyStatusAction extends StrutsAction implements Preparable{
	
	private User user;
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	

	
	private UserManager userManager;
	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}
		
	public String mystatus(){
		
		
		if(isGet()){
			if(user.getLat()==0){
				user.setLat(30.86443655);
				user.setLng(120.0992775);
			}
			return INPUT;
		}else{
			userManager.update(user);
			addActionMessage("My Status update successfully");
			return SUCCESS;
		}
	}

	

	public void prepare() throws Exception {
		String username = (String)getSession().getAttribute("sessionUsername");
		user = userManager.getByUsername(username);
	}


}



